﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _05_ParseURLAddress
{
    class ParseURLAddress
    {
        static void Main(string[] args)
        {
            Console.Write("Enter url address: ");
            string urlAddress = Console.ReadLine();

            int protocolEndIndex = urlAddress.IndexOf("://");
            string protocol = urlAddress.Substring(0, protocolEndIndex);

            int serverFirstIndex = protocolEndIndex + 3;
            int serverLastIndex = urlAddress.IndexOf("/", serverFirstIndex);
            string server = urlAddress.Substring(serverFirstIndex, serverLastIndex - serverFirstIndex);

            string resource = urlAddress.Substring(serverLastIndex);

            Console.WriteLine("[protocol] = " + protocol);
            Console.WriteLine("[server] = " + server);
            Console.WriteLine("[resource] = " + resource);
        }
    }
}
